﻿#ifndef __DAHUA_GENICAM_CFRAME_H__
#define __DAHUA_GENICAM_CFRAME_H__

#include "Defs.h"
#include "Memory/Block.h"
#include "Infra/Vector.h"
#include "Infra/String.h"
#include "PixelType.h"


GENICAM_NAMESPACE_BEGIN

/// \~chinese
/// \brief 鏁版嵁甯у璞℃帴鍙?
/// \defgroup Frame 鏁版嵁甯ф搷浣沧帴鍙?
/// @{
/// \~english 
/// \brief data frame object interface
/// \defgroup data Frame Buffer Operation interface
/// @{

/// \~chinese
/// \brief Class CFrame 鏁版嵁甯у璞℃帴鍙ｏ紝甯х殑闀裤€佸浠ュ强鏁版嵁镙煎纺鍙粠璇ュ璞′腑銮峰彇
/// \~english
/// \brief Class CFrame frame object interface
class GENICAM_API CFrame : public Memory::CBlock
{
public:	

	enum EPayloadType
	{
		payloadImage = 1,	            ///< \~chinese 锲剧墖         \~english Image
		payloadRawdata,					///< \~chinese 瑁告暟鎹?      \~english Raw Data
		payloadFile,					///< \~chinese 鏂囦欢         \~english File
		payloadChunkData,				///< \~chinese 鍧楁暟鎹?      \~english Chunk Data
		payloadExtChunkData,			///< \~chinese 镓╁睍鍧楁暟鎹?  \~english Extension Chunk Data
		payloadJpeg,					///< \~chinese jpeg鏁版嵁     \~english jpeg Data
		payloadDevSpecBase = 0x8000,    ///< \~chinese 璁惧鐗规湁     \~english Device specific payload type
		payloadUndefined				///< \~chinese 链畾涔?	\~english Undefined
	};
	
	/// \~chinese
	/// brief 绌烘瀯阃犲嚱鏁?
	/// \~english
	/// brief Empty Constructor function
	CFrame();
	
	/// \~chinese
	/// brief  甯у璞℃瀯阃犲嚱鏁?
	/// \param [in] other 鏋勯€犲抚瀵硅薄镄勫师濮嬫暟鎹潡瀵硅薄
	/// \~english
	/// brief  Frame object constructor function
	/// \param [in] other raw data object used to contruct frame
	explicit CFrame(Memory::CBlock const& other);
	
	/// \~chinese
	/// \brief 甯ф繁鎷疯礉鍏嬮殕鎺ュ彛
	/// \return 鏂扮殑涓€甯у璞?
	/// \~english
	/// \brief frame deep clone interface
	/// \return new frame object
	CFrame clone();
	
	/// \~chinese
	/// \brief 澶栭溃涓崭娇鐢ㄦ椂闇€瑕佽皟鐢ㄦ鎺ュ彛閲婃斁Image鐩稿叧鍐呭瓨
	/// \return none
	/// \~english
	/// \brief It is required to call this interface to release the image related memory when it is not needed externally
	/// \return none	
	void reset();
	
	/// brief 鏄惁链夋晥
	/// \return 杩斿洖璇ュ抚鏄惁链夋晥
	/// \~english
	/// brief check frame valid or not
	/// \retval < 0 frame invalid
	/// \retval 0   frame valid	
	bool valid() const;
	
	/// \~chinese
	/// \brief 銮峰彇璇ュ抚锲剧墖鏁版嵁镄勫唴瀛橀鍦板潃
	/// \return 杩斿洖璇ュ抚锲剧墖鏁版嵁镄勫唴瀛橀鍦板潃
	/// \~english
	/// \brief Get the starting address of memory of this image data
	/// \return Return the starting address of memory of this image data  	
	const void * getImage() const;
			
	/// \~chinese
	/// \brief 銮峰彇鏁版嵁甯х姸镐?
	/// \return 杩斿洖鏁版嵁甯х姸镐?
	/// \~english
	/// \brief Get status of data frame
	/// \return Return status of data frame
	uint32_t getFrameStatus() const;

	/// \~chinese
	/// \brief 銮峰彇锲剧墖瀹藉害
	/// \return 杩斿洖锲剧墖瀹藉害
	/// \~english
	/// \brief get the width of image
	/// \return the width of image, return 0 when failed	
	uint32_t getImageWidth() const;
		
	/// \~chinese
	/// \brief 銮峰彇锲剧墖楂桦害
	/// \return 杩斿洖锲剧墖楂桦害
	/// \~english 
	/// \brief get the height of image
	/// \return the height of image, return 0 when failed	
	uint32_t getImageHeight() const;
			
	/// \~chinese
	/// \brief 銮峰彇锲剧墖澶у皬
	/// \return 杩斿洖锲剧墖澶у皬
	/// \~english
	/// \brief get the size of image
	/// \return the size of image, return 0 when failed	
	uint32_t getImageSize() const;
			
	/// \~chinese
	/// \brief 銮峰彇锲剧墖镀忕礌镙煎纺
	/// \return 杩斿洖锲剧墖镀忕礌镙煎纺
	/// \~english
	/// \brief get image pixel format
	/// \return image pixel format	
	EPixelType getImagePixelFormat() const;
			 
	/// \~chinese
	/// \brief 銮峰彇锲剧墖镞堕棿鎴?
	/// \return 杩斿洖锲剧墖镞堕棿鎴?
	/// \~english
	/// \brief get timestamp of image
	/// return image time stamp, return 0 when failed	
	uint64_t getImageTimeStamp() const;
			 
	/// \~chinese
	/// \brief 銮峰彇锲剧墖瀵瑰簲镄凚lockId
	/// \return 杩斿洖锲剧墖瀵瑰簲镄凚lockId
	/// \~english
	/// \brief get the block ID of image
	/// \return the image's block ID, return 0 when failed 	
	uint64_t getBlockId() const;
			
	/// \~chinese
	/// \brief 銮峰彇褰揿墠甯ф暟鎹噣钻风被鍨?
	/// \param [out] payloadTypes 褰揿墠甯ф暟鎹被鍨嬬绫婚泦
	/// \return 杩斿洖鏄惁鎴愬姛
	/// \~english
	/// \brief get pay load type of current frame
	/// \param [out] payloadTypes Current frame data type set
	/// \retval false failure
	/// \retval true  success	
	bool getPayLoadTypes(Infra::TVector<EPayloadType>& payloadTypes) const;
			
	/// \~chinese
	/// \brief 銮峰彇Buffer涓寘鍚殑Chunk涓暟
	/// \return Chunk涓暟
	/// \~english
	/// \brief get the number of chunk in buffer
	/// \return the number of chunk	
	uint32_t getChunkCount() const;
	
	/// \~chinese
	/// \brief 銮峰彇Chunk鏁版嵁
	/// \param [in] aIndex 绱㈠紩ID
	/// \param [out] aID ChunkID
	/// \param [out] paramNames Chunk鏁版嵁瀵瑰簲镄勫睘镐у悕
	/// \return 鏄惁鎴愬姛
	/// \~english
	/// \brief get chunk data
	/// \param [in] aIndex index ID
	/// \param [out] aID ChunkID
	/// \param [out] paramNames Corresponding property name of chunk data 
	/// \return success or fail	
	bool getChunkDataByIndex(uint32_t aIndex, uint32_t &aID, Infra::TVector<Infra::CString>& paramNames) const;

    /// \~chinese
    /// \brief 銮峰彇锲剧墖paddingX
    /// \return 杩斿洖锲剧墖paddingX
    /// \~english
    /// \brief get image paddingX
    /// \return paddingX	
    uint32_t getImagePadddingX() const;

    /// \~chinese
    /// \brief 銮峰彇锲剧墖paddingY
    /// \return 杩斿洖锲剧墖paddingY
    /// \~english
    /// \brief get image paddingY
    /// \return paddingY		
    uint32_t getImagePadddingY() const;
};

/// @}

GENICAM_NAMESPACE_END

#endif //__DAHUA_GENICAM_CFRAME_H__

